// pages/list/list.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navArr: [
      {
        title: '热门',
        label: 'hot'
      },
      {
        title: '保洁服务',
        label: 'hot1'
      },
      {
        title: '维修服务',
        label: 'hot2'
      },
      {
        title: '搬家服务',
        label: 'hot3'
      },
      {
        title: '保姆月嫂',
        label: 'hot4'
      },
      {
        title: '管道维修',
        label: 'hot5'
      },
    ],
    wareArr: [
      {
        id: "1",
        title: '',
        label: 'hot'
      },
      {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      },      {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      },      {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      },      {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      },      {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      }, {
        id: "1",
        title: '鸡翅000',
        label: 'hot'
      },
      {
        id: "2",
        title: '鸡翅000',
        label: 'hot'
      },
      {
        id: "3",
        title: '鸡翅0000',
        label: 'hot'
      },
      {
        id: "2",
        title: '鸡翅111111',
        label: 'hot1'
      },
      {
        id: "3",
        title: '鸡翅11111',
        label: 'hot1'
      },
      {
        id: "2",
        title: '鸡翅222',
        label: 'hot2'
      },
      {
        id: "3",
        title: '鸡翅22222',
        label: 'hot2'
      },
      {
        id: "4",
        title: '鸡翅2',
        label: 'hot2'
      },
      {
        id: "4",
        title: '鸡翅2',
        label: 'hot2'
      },
      {
        id: "4",
        title: '鸡翅3333',
        label: 'hot3'
      },
      {
        id: "4",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
      {
        id: "5",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
      {
        id: "6",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
      {
        id: "7",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
      {
        id: "5",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
      {
        id: "5",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
      {
        id: "5",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
      {
        id: "5",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
      {
        id: "5",
        pic: '/common/image/item1.png',
        title: '鸡翅4444',
        label: 'hot4'
      },
    ],
    intoView: '',
    winH: 0,
    initListMap:[],
    shoppingCart: {
      ware: []
    }
  },
  moveToView: function (e) {
    var that = this;
    var label = e.currentTarget.dataset.label;
    that.setData({
      activeLabelGroup: label,
      intoView: label,
    });
  },
  bindContentScroll: function (e) {
    var that = this;
    var initListMap = that.data.initListMap;
    var wareArr = that.data.wareArr;
    var scrollHeight = e.detail.scrollHeight - wx.getSystemInfoSync().windowHeight / 750 * 100;
    var scrollTop = e.detail.scrollTop;
    var itemH = scrollHeight / wareArr.length;

    var i;
    for (i = 0; i < initListMap.length; i++) {
      var minSize = initListMap[i].prevSize != 0 ? itemH * initListMap[i].prevSize : 0;
      var maxSize = itemH * initListMap[i].currentSize;
      if (scrollTop >= minSize && scrollTop <= maxSize) {
        that.setData({
          activeLabelGroup: initListMap[i].label
        });
      }
    }
  },
  //底部
  index: function () {
    app.radTo('../index/index')
  },
  list: function () {
    app.radTo('../lists/lists')
  },
  order: function () {
    app.radTo('../order/order')
  },
  my: function () {
    app.radTo('../my/my')
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    getApp().editTabBar(); 
    var that = this;
    var winH = wx.getSystemInfoSync().windowHeight;
    console.log(winH)
    that.setData({
      winH: winH,
      shoppingCart: app.globalData.shoppingCart
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})